package de.gbeine.java.depview.event;

/**
 * Abstract basic class for events.
 *
 * All events should extend this class.
 * The source of the event should be passed as a constructor argument.
 */
public abstract class Event {

    /**
     * The events source object.
     */
    private final Object source;

    /**
     * Create a new event object.
     * @param pSource The events source object
     */
    protected Event(final Object pSource) {
        this.source = pSource;
    }

    /**
     * Test if an object is the source of the current event.
     * @param pSource The object to test if it is the events source.
     * @return True if the object is the events source, otherwise false
     */
    public final boolean triggeredFrom(final Object pSource) {
        if (null == this.source) {
            return false;
        } else {
            return pSource == this.source;
        }
    }
}
